/**
 * 
 */
package com.roc.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author RenPengFei
 * 
 *         2012-4-12
 */
@Component
public class ApplicationContextUtils implements ApplicationContextAware {

	public static ApplicationContext applicationContext;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.springframework.context.ApplicationContextAware#setApplicationContext
	 * (org.springframework.context.ApplicationContext)
	 */
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.applicationContext = applicationContext;
	}

	public static Object getBean(String beanName){
		Object result = null;
		if(applicationContext != null){
			result=applicationContext.getBean(beanName);
		}
		return result;
	}
	public static void main(String[] args) {
		
	}
}
